<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
var HttPRequest = GetXmlHttpObject();

function doCallAjax(){
	
	alert('Your browser');
	var url = 'checkuser.php';
	var pmeters = "username=" + encodeURI( document.getElementById("txtUsername").value) +
					"&password=" + encodeURI( document.getElementById("txtPassword").value );

		HttPRequest.open('POST',url,true);

		HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		HttPRequest.setRequestHeader("Content-length", pmeters.length);
		HttPRequest.setRequestHeader("Connection", "close");
		HttPRequest.send(pmeters);
		
		
		HttPRequest.onreadystatechange = function()
		{

			if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("mySpan").innerHTML = "Now is Loading...";
			}

			if(HttPRequest.readyState == 4)  // Return Request
			{
				if(HttPRequest.responseText == 'Y')
				{
					window.location = 'index.php';
				}
				else
				{
					document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
				}
			}
			
		}

  }
</script>
</head>
<body>
<h1>Login Form</h1>
<form name="frmMain">
<span id="mySpan"></span>
<table width="274" border="1">
<tr>
<th width="117">
 <div align="left">Username</div></th>
<th><input type="text" name="txtUsername" id="txtUsername" size="20"></th>
</tr>
<tr>
<th width="117">
 <div align="left">Password</div></th>
<th><input type="password" name="txtPassword" id="txtPassword" size="20"></th>
</tr> 
</table>
<br>
<input name="btnLogin" type="button" id="btnLogin" OnClick="JavaScript:doCallAjax();" value="Login">
</form>
</body>
</html>